<?php

/**
 * This file is part of the Framework03 PHP framework.
 * @package Framework03
 * @author Walter Tamboer
 */

// Let's get the root directory, this will be useful when setting all the paths.
$root = dirname(dirname(__FILE__));

// The include paths so that all application items can be found.
set_include_path(get_include_path() . PATH_SEPARATOR . $root . '/../../library');

// Make sure that PHP actually shows the errors.
ini_set('display_errors', true);

// Also make sure that PHP shows startup errors.
ini_set('display_startup_errors', true);

// We want to show all errors including strict errors because we don't make mistakes.
error_reporting(E_ALL | E_STRICT);

// We want automatic loading of classes because we're lazy.
require_once 'FW/Loader.php';
FW_Loader::startAutoLoading();

// Create a new YouTube API instance.
$youTube = new FW_GoogleApi_YouTube();

// Let's create a video query to seatch for something.
$query = $youTube->createVideoQuery();

// We want to search for the game "Braid" because it's the best game ever!
$query->videoQuery = 'Braid XBLA';

// Start at index 10.
$query->startIndex = 10;

// And show a maximum amount of 20 results.
$query->maxResults = 20;

// Order by amount of views.
$query->orderBy = 'viewCount';

// Get the video feed.
$videoFeed = $youTube->getVideoFeed($query);

?>
<table>
    <tr>
        <th>Title</th>
        <th>Description</th>
    </tr>
<?php foreach ($videoFeed as $videoEntry) { ?>
    <tr>
        <td><?php echo $videoEntry->getVideoTitle(); ?></td>
        <td><?php echo $videoEntry->getVideoDescription(); ?></td>
    </tr>
<?php } ?>
</table>